package com.platform.api.bzproject.job;

import com.platform.api.bzproject.service.IDownRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author guoyunfei on 2021/12/25 23:34
 * @className DownRecordJob
 * @description TODO
 * @Version 1.0
 */

@Slf4j
@Component
public class DownRecordJob {

    @Autowired
    private IDownRecordService iDownRecordService;

    @Value("${spring.profiles.active}")
    private String active;
    /**
     * 删除前一天记录
     */
    @Async
    @Scheduled(cron = "0 10 0 1/1 * ?") //每天执行一次
    @Transactional(rollbackFor = Exception.class)
    public void deleteDownRecord(){
        System.out.println("执行了删除方法");
        if("dev".equals(active)){
            System.out.println("执行了删除方法-进入不是生产");
            return;
        }
        iDownRecordService.deleteIntervalData();
    }

}
